﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Logging.Viewer.DataEntities;

namespace Logging.Viewer
{
	public partial class _Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void bSearch_Click(object sender, EventArgs e)
		{
			LoadEvent(tbEventId.Text);
		}

		private void LoadEvent(string eventId)
		{
			using (LOG_DBDataContext dc = new LOG_DBDataContext())
			{
				eventId = tbEventId.Text.Replace("-", String.Empty);
				var logEvent = dc.aspnet_WebEvent_Events.Where(e => e.EventId == eventId).ToArray();

				fvDetails.Visible = true;
				fvDetails.DataSource = logEvent;
				fvDetails.DataBind();
			}
		}

		protected string HtmlEncode(object text)
		{
			string stText = text as string ?? String.Empty;
			return stText.Replace(Environment.NewLine, "<br>");
		}
	}
}
